﻿using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel;

namespace NanoMvvm.Collections
{
    public class DelegateKeyedDictionary<TK, TV> : KeyedCollection<TK, TV>
    {
        private readonly Func<TV, TK> getter;

        public DelegateKeyedDictionary(Func<TV, TK> keyGetter)
        {
            getter = keyGetter;
        }

        protected override TK GetKeyForItem(TV item)
        {
            return getter(item);
        }
    }
}